﻿
using Common.Common;
using DcpServer.Domain;
using System;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBLibrary
{
     public class AppDbContext : DbContext
     {
        public AppDbContext()
        {
            Database.SetInitializer(new AppDbInitializer());
        }

        public DbSet<Patient> Patient { get; set; }

        public DbSet<MainDataTable> MainDataTable { get; set; }

        //数据库初始化，直接连上PgSQL然后建库建表
        public static void Initialize()
        {
            try
            {
                using (var context = new AppDbContext())
                {
                    context.Database.Initialize(true);

                }
            }catch(Exception e)
            {
                LogHelper.Error(e.Message);
            }
            
        }

    }
}
